package easy;

import util.PrintUtils;

public class Solution_1299 {

    public int[] replaceElements(int[] arr) {
        int pre = arr[arr.length - 1];
        for (int i = arr.length - 2; i >= 0; i--) {
            int temp = arr[i];
            arr[i] = Math.max(arr[i + 1], pre);
            pre = temp;
        }
        arr[arr.length - 1] = -1;
        return arr;
    }

    public static void main(String[] args) {
        Solution_1299 model = new Solution_1299();
        PrintUtils.arrayInt(model.replaceElements(new int[]{17, 18, 5, 4, 6, 1}));
        PrintUtils.arrayInt(model.replaceElements(new int[]{400}));
    }
}
